<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set var="ctx" value="${pageContext.request.contextPath}" />

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8"> 
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> 
  <title>乐直播-硬件管理</title> 
  <link rel="stylesheet" href="http://cdn.lezhibo.com/static/layui/css/layui.css?cdnv=0.16"> 
  <link rel="stylesheet" href="http://cdn.lezhibo.com/static/portal/css/le-main24.css?cdnv=0.16"> 
  <link rel="stylesheet" href="http://cdn.lezhibo.com/static/libs/font-awesome/css/font-awesome.min.css?cdnv=0.16"> 
  <style type="text/css">
    .le-loud-img{position:relative;cursor: pointer;}
    .le-confirm-device{position: absolute;top: 0;right: 0;padding: 3px 5px;border: 1px solid;}
    .le-confirm-test{position: absolute;top: 0;right: 0;padding: 3px 5px;border: 1px solid;}
    .le-useing{position: absolute;top: 0;right: 0;padding:3px}
    .le-useing-ing{ position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    width: 100%;
    background-color: rgba(0,0,0,0.6);}

    .le-pages{
    float: right;
    clear:both;
    text-align:center;
    vertical-align:top;
    padding:10px;
    margin-bottom:0;
    }

        </style> 
 </head> 
 <body> 
  <div class="layer-plugin"> 
   <ul class="le-hardware-content"> 
    <li class="live-hover" style="width:23%;height: 220px;" go-href="/portal/activity?id=4e3659f8bf7f44d082ba5f01137f4da3" go-href-new="true"> 
     <div class="live-up2"> 
      <div class="le-loud-img">
       <img style="height:100%" src="http://cdn.lezhibo.com/static/portal/images/activity-default.jpg">
      </div> 
      <div class="live-position"> 
       <div class="live-position-describe"> 
        <p class="live-position-left"> 免费观看 </p> 
        <p class="live-position-right"> <span><i class="fa fa-comments-o" aria-hidden="true"></i> 0</span> <span><i class="fa fa-eye" aria-hidden="true"></i> 0</span> </p> 
       </div> 
      </div> 
      <div class="le-hardware-img2"> 
       <div class="hide le-confirm-device">
        <i class="fa fa-check" aria-hidden="true"></i>
       </div> 
       <div class="hide le-confirm-test">
        <i class="fa fa-check" aria-hidden="true"></i>
       </div> 
       <input name="flag" type="hidden" value="true"> 
      </div> 
     </div> 
     <div class="live-down2"> 
      <h2>付费看看看看看看看</h2> 
     </div> <input class="le-activity-id" type="hidden" value="4e3659f8bf7f44d082ba5f01137f4da3"> </li> 
    <li class="live-hover" style="width:23%;height: 220px;" go-href="/portal/activity?id=8c727e99a17d4c02822cdf3ba4c775c0" go-href-new="true"> 
     <div class="live-up2"> 
      <div class="le-loud-img">
       <img style="height:100%" src="http://cdn.lezhibo.com/static/portal/images/activity-default.jpg">
      </div> 
      <div class="live-position"> 
       <div class="live-position-describe"> 
        <p class="live-position-left"> 免费观看 </p> 
        <p class="live-position-right"> <span><i class="fa fa-comments-o" aria-hidden="true"></i> 0</span> <span><i class="fa fa-eye" aria-hidden="true"></i> 0</span> </p> 
       </div> 
      </div> 
      <div class="le-hardware-img2"> 
       <div class="hide le-confirm-device">
        <i class="fa fa-check" aria-hidden="true"></i>
       </div> 
       <div class="hide le-confirm-test">
        <i class="fa fa-check" aria-hidden="true"></i>
       </div> 
       <input name="flag" type="hidden" value="true"> 
      </div> 
     </div> 
     <div class="live-down2"> 
      <h2>付费观看</h2> 
     </div> <input class="le-activity-id" type="hidden" value="8c727e99a17d4c02822cdf3ba4c775c0"> </li> 
    <li class="live-hover" style="width:23%;height: 220px;" go-href="/portal/activity?id=a4e0d3a517e4441087bb899354ab698c" go-href-new="true"> 
     <div class="live-up2"> 
      <div class="le-loud-img">
       <img style="height:100%" src="http://cdn.lezhibo.com/static/portal/images/activity-default.jpg">
      </div> 
      <div class="live-position"> 
       <div class="live-position-describe"> 
        <p class="live-position-left"> 免费观看 </p> 
        <p class="live-position-right"> <span><i class="fa fa-comments-o" aria-hidden="true"></i> 0</span> <span><i class="fa fa-eye" aria-hidden="true"></i> 5</span> </p> 
       </div> 
      </div> 
      <div class="le-hardware-img2"> 
       <div class="hide le-confirm-device">
        <i class="fa fa-check" aria-hidden="true"></i>
       </div> 
       <div class="hide le-confirm-test">
        <i class="fa fa-check" aria-hidden="true"></i>
       </div> 
       <input name="flag" type="hidden" value="true"> 
      </div> 
     </div> 
     <div class="live-down2"> 
      <h2>测试</h2> 
     </div> <input class="le-activity-id" type="hidden" value="a4e0d3a517e4441087bb899354ab698c"> </li> 
    <li class="live-hover" style="width:23%;height: 220px;" go-href="/portal/activity?id=1dee5b359e6e42c4822d1af3c8a35b86" go-href-new="true"> 
     <div class="live-up2"> 
      <div class="le-loud-img">
       <img style="height:100%" src="http://cdn.lezhibo.com/attachment/20170818/c3ef864d5aec461d9f5b615d61c2c31e.jpg">
      </div> 
      <div class="live-position"> 
       <div class="live-position-describe"> 
        <p class="live-position-left"> 密码观看 </p> 
        <p class="live-position-right"> <span><i class="fa fa-comments-o" aria-hidden="true"></i> 0</span> <span><i class="fa fa-eye" aria-hidden="true"></i> 6</span> </p> 
       </div> 
      </div> 
      <div class="le-hardware-img2"> 
       <div class="hide le-confirm-device">
        <i class="fa fa-check" aria-hidden="true"></i>
       </div> 
       <div class="hide le-confirm-test">
        <i class="fa fa-check" aria-hidden="true"></i>
       </div> 
       <input name="flag" type="hidden" value="true"> 
      </div> 
     </div> 
     <div class="live-down2"> 
      <h2>乐直播直播间</h2> 
     </div> <input class="le-activity-id" type="hidden" value="1dee5b359e6e42c4822d1af3c8a35b86"> </li> 
    <li class="live-hover" style="width:23%;height: 220px;" go-href="/portal/activity?id=a67bb59f9374440f94efa687b8548c24" go-href-new="true"> 
     <div class="live-up2"> 
      <div class="le-loud-img">
       <img style="height:100%" src="http://cdn.lezhibo.com/attachment/20170712/83c60a3572b64f71990bef2f00001075.png">
      </div> 
      <div class="live-position"> 
       <div class="live-position-describe"> 
        <p class="live-position-left"> 免费观看 </p> 
        <p class="live-position-right"> <span><i class="fa fa-comments-o" aria-hidden="true"></i> 6</span> <span><i class="fa fa-eye" aria-hidden="true"></i> 41</span> </p> 
       </div> 
      </div> 
      <div class="le-hardware-img2"> 
       <div class="hide le-confirm-device">
        <i class="fa fa-check" aria-hidden="true"></i>
       </div> 
       <div class="hide le-confirm-test">
        <i class="fa fa-check" aria-hidden="true"></i>
       </div> 
       <input name="flag" type="hidden" value="true"> 
      </div> 
     </div> 
     <div class="live-down2"> 
      <h2>天创恒达上海分部</h2> 
     </div> <input class="le-activity-id" type="hidden" value="a67bb59f9374440f94efa687b8548c24"> </li> 
    <li class="live-hover" style="width:23%;height: 220px;" go-href="/portal/activity?id=9f0a7942491543ecb35c6e55a57cb83b" go-href-new="true"> 
     <div class="live-up2"> 
      <div class="le-loud-img">
       <img style="height:100%" src="http://cdn.lezhibo.com/attachment/20170710/271586d2206d4761975f202923a48305.jpg">
      </div> 
      <div class="live-position"> 
       <div class="live-position-describe"> 
        <p class="live-position-left"> 免费观看 </p> 
        <p class="live-position-right"> <span><i class="fa fa-comments-o" aria-hidden="true"></i> 127</span> <span><i class="fa fa-eye" aria-hidden="true"></i> 300</span> </p> 
       </div> 
      </div> 
      <div class="le-hardware-img2"> 
       <div class="hide le-confirm-device">
        <i class="fa fa-check" aria-hidden="true"></i>
       </div> 
       <div class="hide le-confirm-test">
        <i class="fa fa-check" aria-hidden="true"></i>
       </div> 
       <input name="flag" type="hidden" value="true"> 
      </div> 
     </div> 
     <div class="live-down2"> 
      <h2>天创恒达上海分部</h2> 
     </div> <input class="le-activity-id" type="hidden" value="9f0a7942491543ecb35c6e55a57cb83b"> </li> 
    <li class="live-hover" style="width:23%;height: 220px;" go-href="/portal/activity?id=04813844a39649519aa0f84a33166660" go-href-new="true"> 
     <div class="live-up2"> 
      <div class="le-loud-img">
       <img style="height:100%" src="http://cdn.lezhibo.com/attachment/20170617/49b5d6b4b40f4dca9245c96e32788b65.jpg">
      </div> 
      <div class="live-position"> 
       <div class="live-position-describe"> 
        <p class="live-position-left"> 免费观看 </p> 
        <p class="live-position-right"> <span><i class="fa fa-comments-o" aria-hidden="true"></i> 0</span> <span><i class="fa fa-eye" aria-hidden="true"></i> 13</span> </p> 
       </div> 
      </div> 
      <div class="le-hardware-img2"> 
       <div class="hide le-confirm-device">
        <i class="fa fa-check" aria-hidden="true"></i>
       </div> 
       <div class="hide le-confirm-test">
        <i class="fa fa-check" aria-hidden="true"></i>
       </div> 
       <input name="flag" type="hidden" value="true"> 
      </div> 
     </div> 
     <div class="live-down2"> 
      <h2>ceshi</h2> 
     </div> <input class="le-activity-id" type="hidden" value="04813844a39649519aa0f84a33166660"> </li> 
    <li class="live-hover" style="width:23%;height: 220px;" go-href="/portal/activity?id=75ce1d32a3d74de68cef03ad3f132588" go-href-new="true"> 
     <div class="live-up2"> 
      <div class="le-loud-img">
       <img style="height:100%" src="http://cdn.lezhibo.com/attachment/20170726/92868397339041d99048a6f721fb7109.gif">
      </div> 
      <div class="live-position"> 
       <div class="live-position-describe"> 
        <p class="live-position-left"> 免费观看 </p> 
        <p class="live-position-right"> <span><i class="fa fa-comments-o" aria-hidden="true"></i> 0</span> <span><i class="fa fa-eye" aria-hidden="true"></i> 9</span> </p> 
       </div> 
      </div> 
      <div class="le-useing"> 
       <span>使用中</span> 
       <input name="flag" type="hidden" value="false"> 
      </div> 
     </div> 
     <div class="live-down2"> 
      <h2>信号测试</h2> 
     </div> <input class="le-activity-id" type="hidden" value="75ce1d32a3d74de68cef03ad3f132588"> </li> 
   </ul> 
   <div class="le-pages"> 
    <a href="javascript:;" class="previous disabled">上一页</a> 
    <a href="javascript:;" class="active">1</a> 
    <a href="/portal/liveroom/selectActivity?id=d9c6afa2e0b649afbd56d3c10e6ffc3d&amp;page=2" class="">2</a> 
    <a href="/portal/liveroom/selectActivity?id=d9c6afa2e0b649afbd56d3c10e6ffc3d&amp;page=2" class="next">下一页</a> 
   </div> 
   <div class="clearfix"></div> 
   <hr> 
   <form id="form" action="/portal/liveroom/chooseActivity"> 
    <div class="plugin-btn"> 
     <input class="le-btn-submit" type="hidden" name="activityId" value=""> 
     <input type="hidden" name="id" value="d9c6afa2e0b649afbd56d3c10e6ffc3d"> 
     <button type="button" class="layui-btn" onclick="doSubmit()"> 选择活动</button> 
    </div> 
   </form> 
  </div> 
  <script type="text/javascript" src="http://cdn.lezhibo.com/static/libs/jquery/jquery.min.js?cdnv=0.16"></script> 
  <script type="text/javascript" src="http://cdn.lezhibo.com/static/libs/jquery/jquery.form.min.js?cdnv=0.16"></script> 
  <script type="text/javascript" src="http://cdn.lezhibo.com/static/layui/layui.js?cdnv=0.16"></script> 
  <script type="text/javascript" src="http://cdn.lezhibo.com/static/layui/lay/dest/layui.all.js?cdnv=0.16"></script> 
  <script>

        var cdnPath="http://cdn.lezhibo.com";//cdn路径
        function openLayer(url, title, func) {
            parent.openLayer(url,title,func);
        }
        function layerInit() {
            $("[layer-href]").click(function () {
                openLayer($(this).attr("layer-href"), $(this).attr("layer-title"), $(this).attr("layer-func"))
            });
        }

        $("[confirm-href]").click(function () {
            var href = $(this).attr("confirm-href");
            if ((typeof(href) == "undefined") || href == null || href == "") {
                return;
            }

            var title = $(this).attr("confirm-title");
            if ((typeof(title) == "undefined") || title == null || title == "") {
                title = "您确定执行该操作吗？"
            }
            layer.confirm(title, {icon: 9, title: '确定操作 ？'}, function (index) {
                        layer.close(index);
                        $.get(href, function (result) {
                            if (result.isOk) {
                                location.reload();
                            } else {
                                alert(result.message);
                            }
                        });
                    },
                    function (index) {
                        layer.close(index);
                    });
        });

        var verification ={
            mobiel:function(){
                $mobile = $("input[validate='mobile']").val();
                var re = /^1\d{10}$/;
                if((typeof($mobile)!="undefined") && !re.test($mobile)){
                    $("input[validate='mobile']").after('<p class="le-tips"><span style="color: red;width: 100%">请输入正确的手机号</span></p>');
                    return false;
                }
            },
            empty:function(){
                var $input =$("input[validate='empty']");
                for(var i=0;i<$input.length;i++){
                    if($input.eq(i).val().trim().length==0){
                        $("input[validate='empty']").eq(i).after('<p class="le-tips"><span style="color: red;width: 100%">输入不能为空</span></p>');
                        return false;
                    }
                }

                var $textarea =$("textarea[validate='empty']");
                for(var i=0;i<$textarea.length;i++){
                    if($textarea.eq(i).val().trim().length==0){
                        $("textarea[validate='empty']").eq(i).parent().after('<p class="le-tips"><span style="color: red;width: 100%">输入不能为空</span>/p>');
                        return false;
                    }
                }

                var $select =$("select[validate='empty']");
                for(var i=0;i<$select.length;i++){
                    if($select.eq(i).val().trim().length==0){
                        $("select[validate='empty']").eq(i).parent().after('<p class="le-tips"><span style="color: red;width: 100%">输入不能为空</span></p>');
                        return false;
                    }
                }
            },
            email:function(){
                $email=$("input[validate='email']").val();
                var re = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/;
                if((typeof($email)!="undefined") && !re.test($email)){
                    $("input[validate='email']").after('<span class="le-tips"><span style="color: red;width: 100%">请输入正确的邮箱</span></p>');
                    return false;
                }
            },
            password: function () {
                $password = $("input[validate='password']").val();
                var re = /(.+){6,12}$/;
                if ((typeof($password) != "undefined") && !re.test($password)) {
                    $("input[validate='password']").after('<p class="le-tips"><span style="color: red;width: 100%">请输入6到12位密码</span></p>');
                    return false;
                }
            },
            //正整数
            positiveInteger: function () {
                $positiveInteger = $("input[validate='positiveInteger']");
                var re=/^[1-9]\d*|0$/;
                for (var i = 0; i < $positiveInteger.length; i++) {
                    var every=$positiveInteger.eq(i).val().trim();
                    if ((typeof(every) != "undefined") && !re.test(every)) {
                        $("input[validate='positiveInteger']").eq(i).after('<p class="le-tips"><span style="color: red">请输入一个正整数或者0</span></p>');
                        return false;
                    }
                }
            },
            decimal: function (value) {
                $decimal = $("input[validate='decimal']");
                var re = /^[0-9]+\.{0,1}[0-9]{0,2}$/;
                for (var i = 0; i < $decimal.length; i++) {
                    var every=$decimal.eq(i).val().trim();
                    if ((typeof(every) != "undefined") && !re.test(every)) {
                        $("input[validate='decimal']").eq(i).after('<p class="le-tips"><span style="color: red">值精确到0.01,不能小于0</span></p>');
                        return false;
                    }
                }
            }
         };


        var regularVerify = {
            mobile: function (value) {
                var re = /^1\d{10}$/;
                if ((typeof(value) != "undefined") && !re.test(value)) {
                    return false;
                }
            },
            email: function (value) {
                var re = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/;
                if ((typeof(value) != "undefined") && !re.test(value)) {
                    return false;
                }
            },
            password: function (value) {
                var re = /(.+){6,12}$/;
                if ((typeof(value) != "undefined") && !re.test(value)) {
                    return false;
                }
            },
            integer: function (value)     {
//                    var re = /^[1-9]\d*$/;
                var re = /^\d+$/;
                if ((typeof(value) != "undefined") && !re.test(value)) {
                    return false;
                }
            },
            decimal: function (value) {
//                    var re = /^[1-9]\d*\.\d*|0\.\d*[1-9]\d*$/;
                var re = /^[0-9]+\.{0,1}[0-9]{0,2}$/;
                if ((typeof(value) != "undefined") && !re.test(value)) {
                    return false;
                }
            },
            empty: function (value) {
                if (value.trim().length == 0) {
                    return false;
                }
            }
        }


        function leSubmit(){
        $("[le-submit]").click(function(){
            var sfunc = $("#form").attr("success-func");
            var bfunc = $("#form").attr("before-func");
            $("#form").ajaxSubmit({
                type:"post",
                dataType:"json",
                beforeSend:function(){
                    if(bfunc != null){
                        if(false == eval(bfunc)){
                            return false;
                        }
                    }
                    $(".le-tips").remove();
                    if(false == verification.empty()){
                        return false;
                    }
                    if(false == verification.mobiel()){
                        return false;
                    }
                    if(false == verification.email()){
                        return false;
                    }
                    if(false == verification.password()){
                        return false;
                    }
                    if(false == verification.positiveInteger()){
                        return false;
                    }
                },
                success:function(result){
                    if(sfunc != null){
                        eval(sfunc);
                        return;
                    }

                    if(result.isOk){
                        parent.isUpdateData = true;
                        parent.layer.closeAll();
                    }else{
                        layer.alert(result.message);
                    }
                },
                error:function(){
                    layer.alert("信息提交错误");
                }
            });
        })
}

            layerInit();
        leSubmit();
    $(function(){
        $(".le-hardware-content li").click(function(){
            $(".le-confirm-test").hide();
            $(this).find(".le-confirm-test").show();
            //input[name='flag']用来作为是否可添加的标识，"true"可添加，"false"不可添加
            if($(this).find("input[name='flag']").val()=="true"){
                var $id= $(this).find(".le-activity-id").val();
                $(".le-btn-submit").val($id);
            }else{
                $(".le-btn-submit").val("");
            }
        })


        $(".le-loud-img").mouseover(function(){
            $(this).find(".le-confirm-device").show();
        }).mouseout(function(){
            $(".le-confirm-device").hide();
        })
    })


    function doSubmit(url){
    $("#form").ajaxSubmit({
    type : "post", //提交方式
    dataType : "json", //数据类型
    beforeSubmit : function(){
    $val = $(".le-btn-submit").val();
    if($val==""||$val==null){
    alert("请选择可用活动");
    return false;
    }
    },
    success : function(result) { //提交成功的回调函数
    if(result.isOk){
    parent.isUpdateData = true;
    parent.layer.closeAll();

    }else{
    alert(result.message);
    }
    },
    error : function() {
    alert("信息提交错误");
    }
    });
    }
    </script>   
 </body>
</html>